<!--
 * @Description: 娱乐场所从业
 * @Author: 丁飞洋
 * @Date: 2025-09-10 14:20:52
 * @LastEditTime: 2025-10-13 15:50:55
 * @LastEditors: 丁飞洋
-->
<template>
  <BaseNode>
    <div class="abnormalAccommodation">
      <div class="box">
        <div class="left">
          <a-table :data-source="dataSource" :columns="columns" size="small" :pagination="pagination" :loading="loading"
            @change="handleTableChange">
          </a-table>
        </div>
      </div>
    </div>
  </BaseNode>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { getYLCSList } from "@/api/ZAApi.js";
import { message } from "ant-design-vue";
import BaseNode from "../Node/BaseNode.vue";
const { node } = ref({})

// 首次加载
onMounted(() => {
  sfzh.value = node.data.idCard;
  fetchData();
});
// 加载
const loading = ref(false);
// 人像
const img = ref("");
// 证件号码
const sfzh = ref("");
// 列表数据
const dataSource = ref([]);
// 列表表头
const columns = ref([
  {
    title: "从业场所名称",
    dataIndex: "dwmc",
    ellipsis: true,
    width: "auto",
  },
  {
    title: "从业岗位",
    dataIndex: "zw",
    width: "auto",
  },
  {
    title: "入职日期",
    dataIndex: "rzsj",
    width: "auto",
  },
  {
    title: "离职日期",
    dataIndex: "lzsj",
    width: "auto",
  },
  {
    title: "场所详址",
    dataIndex: "gzdxxdz",
    width: "auto",
  },
]);
const pagination = ref({
  current: 1,
  pageSize: 5,
  total: 0,
  showSizeChanger: false, // 关闭分页大小选择器
});

// 分页改变
const handleTableChange = (pag, filters, sorter) => {
  pagination.value.current = pag.current
  pagination.value.pageSize = pag.pageSize
  fetchData() // 重新获取数据
}

// 请求列表数据
const fetchData = async () => {
  const params = {
    gmsfzhm: sfzh.value,
    pageNo: pagination.value.current,
    pageSize: pagination.value.pageSize,
  };

  loading.value = true;
  getYLCSList(params)
    .then((res) => {
      loading.value = false;
      if (res.code == 200) {
        dataSource.value = res.result.records;
        pagination.total = res.total
      } else {
        message.error(res.msg);
      }
    })
    .catch((err) => {
      loading.value = false;
      message.error(err);
    });
};
</script>

<style scoped>
.abnormalAccommodation {
  min-height: 260px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* border: 1px solid #e5e7eb; */
  padding: 10px 24px;
  overflow-y: auto;
}

.box {
  width: 100%;
  display: flex;
}

.right {
  width: 120px;
  margin-right: 16px;
}

.left {
  flex: 1;
}

.title {
  text-align: center;
  font-size: 16px;
  margin: 8px auto;
}

.img {
  width: 110px;
  height: 128px;
  padding-left: 5px;
}

.text {
  font-size: 12px;
  color: #1677ff;
}
</style>
